@extends('backend.layouts.default')

@section('content')
  <div class="box box-primary">
    <div class="box-header with-border">
      <h3 class="box-title">文章添加</h3>
    </div>
    <form role="form" action="{{ route('posts.store') }}" method="post">
      <div class="box-body">
        <div class="form-group">
          <label for="title">标题</label>
          <input type="text" class="form-control" id="title" name="title" placeholder="" value="{{ old('title') }}">
        </div>
        <div class="form-group">
          <label for="slug">URL标识</label>
          <input type="text" class="form-control" id="slug" name="slug" placeholder="" value="{{ old('slug') }}">
        </div>
        <div class="form-group">
          <label for="tags">标签</label>
          <select2 name="tags[]" multiple="multiple">
            @foreach ($tags as $tag)
              <option value="{{ $tag->name }}" {{ in_array($tag->name, $old_tags) ? 'selected' : '' }}>{{ $tag->name }}</option>
            @endforeach
          </select2>
        </div>
        <div class="form-group">
          <label for="publish_date">发布日期</label>
          <datepicker name="publish_date" value="{{ old('publish_date', date('Y-m-d')) }}"></datepicker>
        </div>
        <div class="form-group">
          <label for="body">内容</label>
          <markdown-editor name="body" value="{{ old('body') }}"></markdown-editor>
        </div>
        @include('backend.layouts.errors')
      </div>
      <div class="box-footer text-right">
        {{ csrf_field() }}
        <button type="submit" class="btn btn-primary">确认</button>
      </div>
    </form>
  </div>
@endsection
